package com.aqie.rabbit.config;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements ApplicationContextAware, WebMvcConfigurer {
    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    // 结尾是否带斜杠均能正常访问
    /*@Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        configurer.setUseSuffixPatternMatch(false).
                setUseTrailingSlashMatch(true);
    }*/

    /*
    @Override
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
        // 是否通过请求Url的扩展名来决定media type
        configurer.favorPathExtension(true)
                // 不检查Accept请求头
                .ignoreAcceptHeader(true)
                .parameterName("mediaType")
                // 设置默认的media type
                .defaultContentType(MediaType.APPLICATION_JSON)
                // 请求以.html结尾的会被当成MediaType.TEXT_HTML
                .mediaType("html", MediaType.TEXT_HTML)
                // 请求以.json结尾的会被当成MediaType.APPLICATION_JSON
                .mediaType("gif", MediaType.APPLICATION_JSON);

    }
    */
}
